﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace B.S.BaseData.Infrastructure.Interface
{
    public interface IBaseRepository<T> where T : class
    {
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> CreateAsync(T entity);
        
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<T> AddAsync(T entity);
        
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <returns></returns>
        Task<int> SaveChangesAsync();
        /// <summary>
        /// 泛型批量修改方法
        /// </summary>
        /// <param name="t">实体</param>
        /// <returns>受影响行数</returns>
        Task<int> UpdateRangAsync(List<T> t);
        /// <summary>
        /// 根据ID获取实体
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> GetByIdAsync(long id);
        
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(T entity);
        
        /// <summary>
        /// 根据编号查询数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<T> GetValue(long id);
        
        Task<T> GetValues(Expression<Func<T, bool>> expression);
        
        /// <summary>
        /// 查询所有数据
        /// </summary>
        /// <returns></returns>
        IQueryable<T> GetAll();
        
        Task<int> Delete(T t);
    }
}
